﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Networking;

namespace ttbit.form.unity
{
    internal class FileIO : IFileIO
    {
        public string[] GetRootPaths()
        {
#if UNITY_EDITOR
            return Environment.GetLogicalDrives();
#else
            return Environment.GetLogicalDrives();
#endif

        }



        public Stream OpenInternalFile(string path)
        {
            var ta = UnityEngine.Resources.Load(path) as TextAsset;
            if (ta == null || ta.bytes == null)
                return null;
            return new System.IO.MemoryStream(ta.bytes);
        }

        public byte[] ReadInternalBin(string path)
        {
            var ta = UnityEngine.Resources.Load(path) as TextAsset;
            if (ta == null || ta.bytes == null)
                return null;
            return ta.bytes;
        }

        public string ReadInternalText(string path)
        {
            var ta = UnityEngine.Resources.Load(path) as TextAsset;
            if (ta == null || ta.text == null)
                return null;
            return ta.text;
        }


    }
}
